package puzzle.projecteuler.p300;

import astudy.util.AdvMath;


public class Problem214B {
	

	/**
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		
		int m = 40000000;
		int len = 25;
		
		long s = System.currentTimeMillis();
		int[] t = AdvMath.phis(m);
		long sum = 0;
		t[1] = 0;
		for (int i = 1; i < t.length; i ++) {
			t[i] = t[t[i]] + 1;
			if (t[i] == len-1 && AdvMath.isPrime(i)) {
				sum += i;
			}
		}
		System.out.println("sum = " + sum);
		System.out.println((System.currentTimeMillis()-s) + " ms");
	}
}
